/***************************************************************************
 创建者: 华磊
 开始时间: 2018.8.14
 copyright: (C) 华友高科
 修改说明: (每次有修改就添加一条，带有 修改人，修改时间，修改描述)
 example (1) hualei 2017.5.8 类的具体实现代码编写

 ***************************************************************************/
#include "paldefine.h"

SUserPoint::SUserPoint()
{
    m_fWorldAngle.resize(6);
    memset(m_fWorldAngle.begin(),0,6);
}

SStackStylePointInfo::SStackStylePointInfo()
{
    m_nMatrix.resize(3);
    memset(m_nMatrix.begin(),0,3);
}

SStackInfo::SStackInfo()
{
    m_nTeachOrder = 1;
    m_nIntervalEnable.resize(3);
    memset(m_nIntervalEnable.begin(),0,3);
    m_nIntervalValue.resize(3);
    memset(m_nIntervalValue.begin(),0,3);
}

PalletizingGoodsData::PalletizingGoodsData()
{
    m_nMatrix.resize(3);
    memset(m_nMatrix.begin(),0,3);


}

QDataStream& operator <<(QDataStream &out,SUserPoint &myVector)
{
    out << (quint32)myVector.m_fWorldAngle.size();
    out << myVector.m_fWorldAngle;

    out << (quint32)myVector.m_fJointAngle.size();
    out << myVector.m_fJointAngle;

    out << (quint32)myVector.m_fTCPMatrix.size();
    for(int i = 0; i < myVector.m_fTCPMatrix.size();i++)
    {
        out << (quint32)myVector.m_fTCPMatrix[i].count();
    }

    for(int i = 0; i < myVector.m_fTCPMatrix.size();i++)
    {
        for(int j = 0; j < myVector.m_fTCPMatrix[i].count();j++)
        {
            out << myVector.m_fTCPMatrix[i][j];
        }
    }

    out << myVector.pointComment;

    out << myVector.configString;

    out << myVector.m_nPointLock;

    out << myVector.groupNum;

    out << myVector.userNum;

    out << myVector.toolNum;

    out << myVector.direction;

    return out;
}

QDataStream& operator >>(QDataStream &in,SUserPoint &myVector)
{
    quint32 c;

    in >> c;
    myVector.m_fWorldAngle.resize(c);
    in >> myVector.m_fWorldAngle;

    in >> c;
    myVector.m_fJointAngle.resize(c);
    in >> myVector.m_fJointAngle;

    in >> c;

    QVector <int> tcpSize;
    quint32 testInt;
    quint32 m;
    for( m = 0 ; m < c; m++)
    {
         in >> testInt;
         tcpSize.append(testInt);
    }

    for( m = 0; m < c; m++)
    {
        for(int n = 0;n < tcpSize[m];n++)
        {
            myVector.m_fTCPMatrix[m].resize(n+1);
            in >> myVector.m_fTCPMatrix[m][n];
        }
    }

    in >> myVector.pointComment;

    in >> myVector.configString;

    in >> myVector.m_nPointLock;

    in >> myVector.groupNum;

    in >> myVector.userNum;

    in >> myVector.toolNum;

    in >> myVector.direction;

    return in;
}

QDataStream& operator <<(QDataStream &out,SStackStylePointInfo &myVector)
{
    out << (quint32)myVector.m_nMatrix.size();
    out << myVector.m_nMatrix;

    out << myVector.m_sStackPoint;

    return out;
}

QDataStream& operator >>(QDataStream &in,SStackStylePointInfo &myVector)
{
    quint32 c;
    in >> c;
    myVector.m_nMatrix.resize(c);
    in >> myVector.m_nMatrix;

    in >> myVector.m_sStackPoint;

    return in;
}

QDataStream& operator <<(QDataStream &out,SStackInfo &myVector)
{
    out << myVector.stackName;
    out << myVector.m_nStackUpDown;
    out << myVector.m_nRow;
    out << myVector.m_nCol;
    out << myVector.m_nLayer;
    out << myVector.m_nExecIncr;
    out << myVector.m_nAuxiliary;
    out << myVector.m_nExecOrder;
    out << myVector.m_nTeachOrder;

    out << (quint32)myVector.m_nIntervalEnable.size();
    out << myVector.m_nIntervalEnable;

    out << (quint32)myVector.m_nIntervalValue.size();
    out << myVector.m_nIntervalValue;

    out << myVector.m_nStackExistAlready;
    out << myVector.m_nStackType;
    out << myVector.m_nStackNumber;
    out << myVector.m_nStackProximityCount;
    out << myVector.m_nStackFleeCount;
    out << myVector.m_nStackStyleCount;
    out << myVector.m_nStackRegister;
    out << myVector.m_nStackPointCount;
    out << myVector.m_nStackFinishOutputMode;
    out << myVector.m_nStackFinishOutputDoNum;

    out << (quint32)myVector.stackPointA_n.size();
    for(int i = 0; i < myVector.stackPointA_n.size();i++)
    {
        out << myVector.stackPointA_n[i];
    }

    out << myVector.stackPointBTM;

    out << (quint32)myVector.stackPointR_n.size();
    for(int i = 0; i < myVector.stackPointR_n.size();i++)
    {
        out << myVector.stackPointR_n[i];
    }

    out << (quint32)myVector.m_sStackStylePointInfo.size();

    for(int i = 0; i < myVector.m_sStackStylePointInfo.size();i++)
    {
        out << myVector.m_sStackStylePointInfo[i];
    }

    return out;

}

QDataStream& operator >>(QDataStream &in,SStackInfo &myVector)
{
    quint32 c;

    in >> myVector.stackName;
    in >> myVector.m_nStackUpDown;
    in >> myVector.m_nRow;
    in >> myVector.m_nCol;
    in >> myVector.m_nLayer;
    in >> myVector.m_nExecIncr;
    in >> myVector.m_nAuxiliary;
    in >> myVector.m_nExecOrder;
    in >> myVector.m_nTeachOrder;

    in >> c;
    myVector.m_nIntervalEnable.resize(c);
    in >> myVector.m_nIntervalEnable;

    in >> c;
    myVector.m_nIntervalValue.resize(c);
    in >> myVector.m_nIntervalValue;

    in >> myVector.m_nStackExistAlready;
    in >> myVector.m_nStackType;
    in >> myVector.m_nStackNumber;
    in >> myVector.m_nStackProximityCount;
    in >> myVector.m_nStackFleeCount;
    in >> myVector.m_nStackStyleCount;
    in >> myVector.m_nStackRegister;
    in >> myVector.m_nStackPointCount;
    in >> myVector.m_nStackFinishOutputMode;
    in >> myVector.m_nStackFinishOutputDoNum;

    in >> c;
    myVector.stackPointA_n.resize(c);
    for(int i = 0; i < c; i++)
    {
        in >> myVector.stackPointA_n[i];
    }

    in >> myVector.stackPointBTM;

    in >> c;
    myVector.stackPointR_n.resize(c);
    for(int i = 0; i < c; i++)
    {
        in >> myVector.stackPointR_n[i];
    }

    in >> c;
    myVector.m_sStackStylePointInfo.resize(c);
    for(int i = 0; i < c;i++)
    {
        in >> myVector.m_sStackStylePointInfo[i];
    }

    return in;
}

QDataStream& operator <<(QDataStream &out,PalletizingGoodsData &myVector)
{
    out << (quint32)myVector.m_nMatrix.size();
    out << myVector.m_nMatrix;

    out << (quint32)myVector.m_sStackPointA_n.size();
    for(int i = 0;i < myVector.m_sStackPointA_n.size();i++)
    {
        out << (quint32)myVector.m_sStackPointA_n[i].count();
    }

    for(int i = 0; i < myVector.m_sStackPointA_n.size();i++)
    {
        for(int j = 0; j < myVector.m_sStackPointA_n[i].count();j++)
        {
            out << myVector.m_sStackPointA_n[i][j];
        }
    }

    out << (quint32)myVector.m_sStackPointBTM.size();
    out << myVector.m_sStackPointBTM;

    out << (quint32)myVector.m_sStackPointR_n.size();
    for(int i = 0; i < myVector.m_sStackPointR_n.size();i++)
    {
        out << (quint32)myVector.m_sStackPointR_n[i].count();
    }

    for(int i = 0;i < myVector.m_sStackPointR_n.size();i++)
    {
        for(int j = 0; j < myVector.m_sStackPointR_n[i].count();j++)
        {
            out << myVector.m_sStackPointR_n[i][j];
        }
    }

    return out;
}

QDataStream& operator >>(QDataStream &in,PalletizingGoodsData &myVector)
{
    quint32 c;
    in >> c;
    myVector.m_nMatrix.resize(c);
    in >> myVector.m_nMatrix;

    in >> c;
    myVector.m_sStackPointA_n.resize(c);
    QVector <int> stackPoint;
    stackPoint.clear();
    stackPoint.resize(c);
    quint32 testInt;
    for(int i = 0;i < c;i++)
    {
        in >> testInt;
        stackPoint[i] = testInt;
    }

    for(int i = 0; i < c;i++)
    {
        for(int j = 0;j < stackPoint[i];j++)
        {
            myVector.m_sStackPointA_n[i].resize(j+1);
            in >> myVector.m_sStackPointA_n[i][j];
        }
    }

    in >> c;
    myVector.m_sStackPointBTM.resize(c);
    in >> myVector.m_sStackPointBTM;

    in >> c;
    myVector.m_sStackPointR_n.resize(c);
    stackPoint.clear();
    stackPoint.resize(c);
    for(int i = 0;i < c;i++)
    {
        in >> testInt;
        stackPoint[i] = testInt;
    }

    for(int i = 0; i < c;i++)
    {
        for(int j = 0; j < stackPoint[i];j++)
        {
            in >> myVector.m_sStackPointR_n[i][j];
        }
    }

    return in;
}
